package com.sx.gongzhong.activity;

import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.sx.gongzhong.BaseActivity;
import com.sx.gongzhong.R;
import com.sx.gongzhong.adapter.LegalTypeSelectAdapter;
import com.sx.gongzhong.model.LegalAdviceTypeBean;
import com.sx.gongzhong.pest.LegalTypeSelectPest;
import com.sx.gongzhong.utils.ToastUtils;
import com.sx.gongzhong.view.LegalTypeSelectView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 法律咨询类型选择
 */
public class LegalTypeSelectActivity extends BaseActivity implements LegalTypeSelectView {

    @BindView(R.id.swipeRefreshLayout)
    SwipeRefreshLayout swipeRefreshLayout;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;

    @Override
    public void setUI(Bundle savedInstanceState) {
        setContentView(R.layout.refresh_list);
        ButterKnife.bind(this);
        setTitleName(R.string.legal_advice_type_select);
        getData();
    }

    public void getData() {
        new LegalTypeSelectPest(this).getLegalTypeSelectListData();
    }

    @Override
    public void showError(String message) {
        ToastUtils.showToast(LegalTypeSelectActivity.this,message);
    }

    @Override
    public void getSuccess(List<LegalAdviceTypeBean> rows) {
        initView(rows);
    }


    private void initView(List<LegalAdviceTypeBean> rows) {
//        if (swipeRefreshLayout != null) {
//            swipeRefreshLayout.setColorSchemeResources(AppConstants.colors);
//            swipeRefreshLayout.setOnRefreshListener(this);
//        }
        recyclerView.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false));
        LegalTypeSelectAdapter selectAdapter = new LegalTypeSelectAdapter(this,R.layout.item_type_list,rows);
        selectAdapter.setEmptyView(View.inflate(this,R.layout.load_error_view,null));
        recyclerView.setAdapter(selectAdapter);
//        selectAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
//            @Override
//            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
//
//            }
//        });
    }
}
